import {
    applyMiddleware,
    legacy_createStore
} from 'redux'
import thunk from "redux-thunk"
import logger from "redux-logger"

import {SETLISTTYPE,ALLACTIONS,DATATYPE,SETFENLEITYPE} from "../types/router.d"

const initialState = {
    list:[],
    fenlei:[]
}

const reducer= (state:DATATYPE = initialState, { type, payload }:ALLACTIONS) => {
  switch (type) {

  case SETLISTTYPE:
    state.list=payload
    return { ...state, ...payload }

  case SETFENLEITYPE:
    state.fenlei=payload
    return { ...state, ...payload }

  default:
    return state
  }
}

const store=legacy_createStore(reducer,applyMiddleware(thunk,logger))

export default store
